/*    */ package com.zimbra.cs.account.ldap.upgrade;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.util.StringUtil;
/*    */ import com.zimbra.cs.account.Entry;
/*    */ import com.zimbra.cs.account.Entry.EntryType;
/*    */ import com.zimbra.cs.account.ldap.LdapProv;
/*    */ import com.zimbra.cs.ldap.LdapClient;
/*    */ import com.zimbra.cs.ldap.LdapServerType;
/*    */ import com.zimbra.cs.ldap.LdapUsage;
/*    */ import com.zimbra.cs.ldap.ZLdapContext;
/*    */ import java.util.Arrays;
/*    */ import java.util.HashMap;
/*    */ import java.util.Map;
/*    */ import java.util.Set;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class BUG_68891
/*    */   extends UpgradeOp
/*    */ {
/*    */   private static final String ATTR_NAME = "zimbraGalLdapAttrMap";
/* 36 */   private static final String[] VALUES = { "zimbraDistributionListSubscriptionPolicy=zimbraDistributionListSubscriptionPolicy", "zimbraDistributionListUnsubscriptionPolicy=zimbraDistributionListUnsubscriptionPolicy" };
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */   void doUpgrade()
/*    */     throws ServiceException
/*    */   {
/* 44 */     ZLdapContext zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.UPGRADE);
/*    */     try {
/* 46 */       doGlobalConfig(zlc);
/*    */     } finally {
/* 48 */       LdapClient.closeContext(zlc);
/*    */     }
/*    */   }
/*    */   
/*    */   Description getDescription()
/*    */   {
/* 54 */     return new Description(this, new String[] { "zimbraGalLdapAttrMap" }, new Entry.EntryType[] { Entry.EntryType.GLOBALCONFIG }, null, Arrays.deepToString(VALUES), String.format("Add values %s on %s", new Object[] { Arrays.deepToString(VALUES), "zimbraGalLdapAttrMap" }));
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */   private void doEntry(ZLdapContext zlc, Entry entry)
/*    */     throws ServiceException
/*    */   {
/* 63 */     String entryName = entry.getLabel();
/*    */     
/* 65 */     this.printer.println();
/* 66 */     this.printer.println("------------------------------");
/* 67 */     this.printer.println("Checking zimbraGalLdapAttrMap on " + entryName);
/*    */     
/* 69 */     Set<String> curValues = entry.getMultiAttrSet("zimbraGalLdapAttrMap");
/*    */     
/* 71 */     Map<String, Object> attrs = new HashMap();
/* 72 */     for (String value : VALUES) {
/* 73 */       if (!curValues.contains(value)) {
/* 74 */         StringUtil.addToMultiMap(attrs, "+zimbraGalLdapAttrMap", value);
/*    */       }
/*    */     }
/* 77 */     modifyAttrs(entry, attrs);
/*    */   }
/*    */   
/*    */   private void doGlobalConfig(ZLdapContext zlc) throws ServiceException {
/* 81 */     doEntry(zlc, this.prov.getConfig());
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/ldap/upgrade/BUG_68891.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */